﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace Elektronix.Class
{
    public class sehirlerulkeler
    {
        public  int ulkeID { get; set; }
        public  int sehirID { get; set; }
        public string ulke { get; set; }
        public string sehir { get; set; }



        public static List<sehirlerulkeler> ulkelerigetir()
        {
            List<sehirlerulkeler> lst = new List<sehirlerulkeler>();
            SqlConnection sqlcon = connection.baglanti;
            SqlCommand sqlcmd = new SqlCommand("select * from ulkeler", sqlcon);

            sqlcon.Open();

            SqlDataReader sdr = sqlcmd.ExecuteReader();

            while (sdr.Read())
            {
                sehirlerulkeler s = new sehirlerulkeler();
                s.ulkeID = Convert.ToInt32(sdr["ulkeID"]);
                s.ulke = sdr["ulke"].ToString();

                lst.Add(s);
            }

            sqlcon.Close();

            return lst;

        }


        public static List<sehirlerulkeler> sehirgietirID(int ID)
        {
            List<sehirlerulkeler> lst = new List<sehirlerulkeler>();

            SqlConnection sqlcon = connection.baglanti;
            SqlCommand sqlcmd = new SqlCommand("select * from sehirler where ulkeID=@ulkeID",sqlcon);
            sqlcmd.Parameters.AddWithValue("@ulkeID",ID);

            sqlcon.Open();

            SqlDataReader sdr = sqlcmd.ExecuteReader();
            while (sdr.Read())
            {
                sehirlerulkeler s = new sehirlerulkeler();
                s.sehirID = Convert.ToInt32(sdr["sehirID"]);
                s.sehir = sdr["sehir"].ToString();

                lst.Add(s);
            }

            sqlcon.Close();

            return lst;
        }


    }
}